package com.tiancheng.trade.payment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiancheng.trade.payment.bo.SettleDistErrorBO;
import com.tiancheng.trade.payment.mapper.SettleDistErrorMapper;
import com.tiancheng.trade.payment.model.SettleDistError;
import com.tiancheng.trade.payment.service.SettleDistErrorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * @Author: likailun
 * @Description:
 * @Date: create in 2022/12/2 16:41
 */
@Slf4j
@Service
public class SettleDistErrorServiceImpl implements SettleDistErrorService {
    @Resource
    private SettleDistErrorMapper settleDistErrorMapper;

    @Override
    public void saveBatch(List<SettleDistError> details) {
        settleDistErrorMapper.saveBatch(details);
    }

    @Override
    public void updateBatch(List<SettleDistError> settleDistErrors) {
        settleDistErrorMapper.updateBatch(settleDistErrors);
    }

    @Override
    public List<SettleDistErrorBO> queryDateSettle() {
        return settleDistErrorMapper.queryDateSettle();
    }

    @Override
    public List<SettleDistError> queryByBatchDistIds(List<String> distIds) {
        if(CollectionUtils.isEmpty(distIds)){
            return Collections.emptyList();
        }
        final QueryWrapper<SettleDistError> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("batch_dist_id",distIds);
        return settleDistErrorMapper.selectList(queryWrapper);
    }
}
